<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="checkbox" id="ck" />全选
	<hr />
	<div id="div">
		<input type="checkbox" name="cb"/>1<br />
		<input type="checkbox" name="cb"/>2<br />
		<input type="checkbox" name="cb"/>3<br />
		<input type="checkbox" name="cb"/>4<br />
		<input type="checkbox" name="cb"/>5
	</div>
    <script>
        document.getElementById("ck").onclick = function(){
            let ocbs = document.getElementsByName("cb");
            for(let i = 0;i < ocbs.length;i ++){
                ocbs[i].checked = this.checked;
            }

        }
    </script>

</body>
</html>